package com.frxuexi.base.http

import com.frxuexi.base.entity.CartBean
import com.frxuexi.base.entity.CommentBean
import com.frxuexi.base.entity.CommentBeanItem
import com.frxuexi.base.entity.CreateOrderBean
import com.frxuexi.base.entity.GetPreOrderBean
import com.frxuexi.base.entity.HomeBean
import com.frxuexi.base.entity.PreOrderBean
import com.frxuexi.base.entity.PreOrderRespBean
import com.frxuexi.base.entity.Res
import com.frxuexi.base.entity.ShopBean
import com.frxuexi.base.entity.ShopDetailBean
import kotlinx.coroutines.flow.Flow
import okhttp3.RequestBody
import retrofit2.http.Body
import retrofit2.http.GET
import retrofit2.http.POST
import retrofit2.http.Path
import retrofit2.http.Query

interface ShopApiService {

    @GET("/api/front/index/product/{type}?limit=10&page=1")
    fun getShops(@Path("type")type:Int):Flow<Res<ShopBean>>

    @GET("/api/front/index")
    fun getHomeData():Flow<Res<HomeBean>>

    @GET("/api/front/product/detail/{id}?type=normal")
    fun getShopDetail(@Path("id")id:Int):Flow<Res<ShopDetailBean>>

    @GET("/api/front/reply/list/{id}?limit=20")
    fun getCommemts(@Path("id")id:Int,@Query("page")page:Int,@Query("type")type:Int):Flow<Res<CommentBean>>

    @POST("/api/front/cart/save")
    fun addCart(@Body body: RequestBody):Flow<Res<Any>>

    @GET("/api/front/cart/list?isValid=true&limit=20")
    fun getCarts(@Query("page")page:Int):Flow<Res<CartBean>>

    @POST("/api/front/cart/num")
    fun updateCart(@Query("id")id:Int,@Query("number")number:Int):Flow<Res<String>>

    @POST("/api/front/cart/delete")
    fun deleteCart(@Query("ids")ids:List<Int>):Flow<Res<String>>

    @POST("/api/front/order/pre/order")
    fun preOrder(@Body body: RequestBody):Flow<Res<PreOrderRespBean>>

    @GET("/api/front/order/load/pre/{preOrderNo}")
    fun getPreOrder(@Path("preOrderNo")preOrderNo:String):Flow<Res<GetPreOrderBean>>

    @POST("/api/front/order/create")
    fun createOrder(@Body body: RequestBody):Flow<Res<CreateOrderBean>>

}